#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
# @FileName  :jobs.py
# @Time      :2022/4/22 11:35 AM
# @Author    :Toliong toliong@foxmail.com
"""
"""
# A schema is used to validate data we receive 
# as well as to reformat the data that we want to send to the client/browser.
# 模式用于验证接收到的数据，以及重新格式化想要发送给客户机/浏览器的数据。
"""
from typing import Optional
from pydantic import BaseModel
from datetime import date, datetime


class JobBase(BaseModel):
    title: Optional[str] = None
    company: Optional[str] = None
    company_url: Optional[str] = None
    location: Optional[str] = None
    description: Optional[str] = None
    date_posted: Optional[date] = datetime.now().date()


class JobCreate(JobBase):
    title: str
    company: str
    location: str
    description: str


class ShowJob(JobBase):
    title: str
    company: str
    company_url: Optional[str]
    location: str
    date_posted: date
    description: Optional[str]

    class Config():   # to convert non dict obj to json
        orm_mode = True


if __name__ == "__main__":
    pass
